package demo.model;

import engine.camera.FlyoverCamera;
import engine.core.scene.Scene;
import engine.gameObject.GameObject;
import engine.gameObject.model.Model;
import engine.light.EnvironmentLight;
import engine.material.Material;
import engine.util.collada.ColladaLoader;

public class ModelScene extends Scene {

	public ModelScene(String name) {
		super(name);
	}

	@Override
	public void init() {
		setupCamera();
		
		GameObject model = ColladaLoader.importFile("model/demo/model/astroboy_walk.dae");
		for(GameObject child: model.getChildren()) {
			if(child instanceof Model) {
				((Model)child).setMaterial(Material.GRAY);
			}
		}
		addGameObject(model);
		
		setupLight();
	}
	
	private void setupCamera() {
		FlyoverCamera cam = new FlyoverCamera();
		cam.setNearPane(100);
		cam.setFarPane(200);
		cam.setPosition(0, 8, 25, 180, 0);
		setCurrentCamera(cam);
	}
	
	private void setupLight() {
		EnvironmentLight light = new EnvironmentLight();
		light.setAmbient(0.5f, 0.5f, 0.5f);
		light.setDirection(-1, 1, -1);
		light.setDiffuse(0.5f, 0.5f, 0.5f);
		addLight(light);
	}
}
